home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 11349 < prev    next >
Encoding:
Text File  |  1996-08-05  |  886 b   |  37 lines

  1. Path: news.aimnet.com!news
  2. From: Ramnivas Laddad <ramnivas@digit.com>
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: mixing static and const qualifiers for class members
  5. Date: 14 Mar 1996 03:03:42 GMT
  6. Organization: Aimnet Information Services
  7. Message-ID: <4i82ae$cq3@news.aimnet.com>
  8. References: <4i6mu3$pmg@halon.vggas.com>
  9. NNTP-Posting-Host: ren.digit.com
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 1.1N (X11; I; SunOS 4.1.3 sun4c)
  14. X-URL: news:4i6mu3$pmg@halon.vggas.com
  15.  
  16. For integers simply use enum
  17. class Foo
  18. {
  19.     enum { nPositions = 6};
  20.     int nData[nPositions];
  21. }
  22.  
  23. For other than integer type, decalre const static in class definition
  24. and initialize it in one of the implementation file (typically, where
  25. Foo is implemented)
  26.  
  27. // Foo.h
  28. class Foo
  29. {
  30.     const static double d;
  31. };
  32.  
  33. // Foo.cpp
  34.  
  35. const double Foo::d = 5.8627675789;
  36.  
  37.